<template>
    <div>
      <div class="goods-tabs">
        <div class="goods-tabs">
          <div class="goods-comment">
            <div class="head">
              <div class="data">
                <p>
                  <span>{{ arr.salesCount }}</span>
                  <span>人购买</span>
                </p>
                <p>
                  <span>{{ arr.praisePercent }}</span>
                  <span>好评率</span>
                </p>
              </div>
              <div class="tags">
                <div class="dt">大家都在说：</div>
                <div class="dd">
                  <a
                    href="javascript:;"
                    :class="{ active: show == 4 }"
                    @click="dian"
                    >全部评价({{ arr.evaluateCount }})</a
                  >
                  <a
                    href="javascript:;"
                    :class="{ active: show == 5 }"
                    @click="dian1"
                    >有图({{ arr.hasPictureCount }})</a
                  >
                  <a
                    href="javascript:;"
                    v-for="(i, index) in arr.tags"
                    :key="index"
                    @click="clk(index, i)"
                    :class="{ active: show == index }"
                    >{{ i.title }}({{ i.tagCount }})</a
                  >
                </div>
              </div>
            </div>
            <div class="sort">
              <span>排序：</span>
              <a :class="{ active: mr == 0 }" href="javascript:;" @click="mrxx"
                >默认</a
              >
              <a :class="{ active: mr == 1 }" href="javascript:;" @click="zx"
                >最新</a
              >
              <a :class="{ active: mr == 2 }" href="javascript:;" @click="zr"
                >最热</a
              >
            </div>
  
            <div class="list">
              <div class="item" v-for="(i, index) in arr1.items" :key="index">
                <div class="user">
                  <img :src="i.member.avatar" alt />
                  <span>{{ i.member.nickname }}</span>
                </div>
                <div class="body">
                  <div class="score">
                    <el-rate
                      v-model="i.score"
                      disabled
                      text-color="#ff9900"
                      score-template="{value}"
                    ></el-rate>
  
                    <span
                      class="attr"
                      v-for="(j, ind) in i.orderInfo.specs"
                      :key="ind"
                      >{{ j.name }}:{{ j.nameValue }}</span
                    >
                  </div>
  
                  <div class="text">{{ i.content }}</div>
  
                  <div class="goods-comment-image" v-if="i.pictures.length">
                    <div class="list">
                      <a
                        class
                        href
                        v-for="(z, index3) in i.pictures"
                        :key="index3"
                      >
                        <img :src="z" alt />
                      </a>
                    </div>
                  </div>
  
                  <div class="time">
                    <span>{{ i.createTime }}</span>
                    <span class="zan">
                      <i class="iconfont icon-thumbs-o-up"></i>
                      {{ i.praiseCount }}
                    </span>
                  </div>
                </div>
              </div>
            </div>
  
            <div class="xtx-pagination">
              <a
                href="javascript:;"
                :class="{ disabled: page == 1 }"
                @click="jian"
                >上一页</a
              >
              <a
                href="javascript:;"
                v-for="(i, index) in arr1.pages"
                :key="index"
                :class="{ active: page == i }"
                @click="spanm(i)"
                >{{ i }}</a
              >
              <a
                href="javascript:;"
                @click="jia"
                :class="{ disabled: page == arr1.pages }"
                >下一页</a
              >
            </div>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script>
  import axios from "axios";
  export default {
    data() {
      return {
        arr: [],
        arr1: [],
        show: 4,
        index1: 0,
        page: 1,
        mr: 0,
        hasPicture: false,
        tag: "",
        sortField: "",
        ifQh: true,
      };
    },
    mounted() {
      axios
        .get("https://mock.boxuegu.com/mock/1175/goods/4026116/evaluate")
        .then((res) => {
          if (res.data.msg == "查询成功") {
            this.arr = res.data.result;
          }
        });
      this.jiekou();
    },
    methods: {
      jiekou() {
        axios({
          url: ` https://mock.boxuegu.com/mock/1175/goods/4026116/evaluate/page`,
          params: {
            page: this.page,
            pageSize: 10,
            hasPicture: this.hasPicture,
            tag: this.tag,
            sortField: this.sortField,
          },
          method: "get",
        }).then((res) => {
          this.arr1 = res.data.result;
        });
      },
      clk(index, i) {
        this.show = index;
        this.page = 1;
        this.tag = i.title;
        this.hasPicture = false;
        this.jiekou();
      },
      dian() {
        this.show = 4;
        this.tag = "";
        this.hasPicture = false;
        this.jiekou();
      },
      dian1() {
        this.show = 5;
        this.tag = "";
        this.hasPicture = false;
        this.hasPicture = true;
        this.jiekou();
      },
      jia() {
        if (this.page < this.arr1.pages) {
          this.page++;
          this.jiekou();
        }
      },
      jian() {
        if (this.page > 1) {
          this.page--;
          this.jiekou();
        }
      },
      spanm(i) {
        this.page = i;
        this.jiekou();
      },
      mrxx() {
        this.mr = 0;
        this.page = 1;
        this.jiekou();
      },
      zx() {
        this.mr = 1;
        this.page = 1;
        this.sortField = "createTime";
        this.jiekou();
      },
      zr() {
        this.mr = 2;
        this.page = 1;
        this.sortField = "praiseCount";
        this.jiekou();
      },
    },
  };
  </script>
  
  <style  scoped>
  .xtx-pagination > a.disabled {
    cursor: not-allowed;
    opacity: 0.4;
  }
  .el-rate {
    float: left;
    margin-top: 10px;
  }
  .goods-tabs {
    width: 940px;
  }
  .goods-relevant[data-v-f1713bb2] {
    background: #fff;
    min-height: 460px;
    margin-top: 20px;
  }
  .goods-relevant .header[data-v-f1713bb2] {
    height: 80px;
    line-height: 80px;
    padding: 0 20px;
  }
  .goods-relevant .header .title[data-v-f1713bb2] {
    font-size: 20px;
    padding-left: 10px;
  }
  .goods-relevant .header .icon[data-v-f1713bb2] {
    width: 16px;
    height: 16px;
    display: inline-block;
    border-top: 4px solid #27ba9b;
    border-right: 4px solid #27ba9b;
    box-sizing: border-box;
    position: relative;
    transform: rotate(45deg);
  }
  .goods-relevant .header .icon[data-v-f1713bb2]:before {
    content: "";
    width: 10px;
    height: 10px;
    position: absolute;
    left: 0;
    top: 2px;
    background: #bcf1e6;
  }
  [data-v-f1713bb2] .xtx-carousel {
    height: 380px;
  }
  [data-v-f1713bb2] .xtx-carousel .carousel-indicator {
    bottom: 30px;
  }
  [data-v-f1713bb2] .xtx-carousel .carousel-indicator span.active {
    background: #27ba9b;
  }
  [data-v-f1713bb2] .xtx-carousel .carousel-btn {
    top: 110px;
    opacity: 1;
    background: transparent;
    color: #ddd;
  }
  [data-v-f1713bb2] .xtx-carousel .carousel-btn i {
    font-size: 30px;
  }
  .goods-image[data-v-d1fd3ff6] {
    width: 480px;
    height: 400px;
    position: relative;
    display: flex;
    z-index: 500;
  }
  .goods-image .large[data-v-d1fd3ff6] {
    position: absolute;
    top: 0;
    left: 412px;
    width: 400px;
    height: 400px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    background-repeat: no-repeat;
    background-size: 800px 800px;
    background-color: #f8f8f8;
  }
  .goods-image .middle[data-v-d1fd3ff6] {
    width: 400px;
    height: 400px;
    background: #f5f5f5;
    position: relative;
    cursor: move;
  }
  .goods-image .middle .layer[data-v-d1fd3ff6] {
    width: 200px;
    height: 200px;
    background: rgba(0, 0, 0, 0.2);
    left: 0;
    top: 0;
    position: absolute;
  }
  .goods-image .small[data-v-d1fd3ff6] {
    width: 80px;
  }
  .goods-image .small li[data-v-d1fd3ff6] {
    width: 68px;
    height: 68px;
    margin-left: 12px;
    margin-bottom: 15px;
    cursor: pointer;
  }
  .goods-image .small li.active[data-v-d1fd3ff6],
  .goods-image .small li[data-v-d1fd3ff6]:hover {
    border: 2px solid #27ba9b;
  }
  .goods-sales[data-v-34ceb5ea] {
    display: flex;
    width: 400px;
    align-items: center;
    text-align: center;
    height: 140px;
  }
  .goods-sales li[data-v-34ceb5ea] {
    flex: 1;
    position: relative;
  }
  .goods-sales li ~ li[data-v-34ceb5ea]:after {
    position: absolute;
    top: 10px;
    left: 0;
    height: 60px;
    border-left: 1px solid #e4e4e4;
    content: "";
  }
  .goods-sales li p[data-v-34ceb5ea]:first-child {
    color: #999;
  }
  .goods-sales li p[data-v-34ceb5ea]:nth-child(2) {
    color: #cf4444;
    margin-top: 10px;
  }
  .goods-sales li p[data-v-34ceb5ea]:last-child {
    color: #666;
    margin-top: 10px;
  }
  .goods-sales li p:last-child i[data-v-34ceb5ea] {
    color: #27ba9b;
    font-size: 14px;
    margin-right: 2px;
  }
  .goods-sales li p[data-v-34ceb5ea]:last-child:hover {
    color: #27ba9b;
    cursor: pointer;
  }
  .g-name[data-v-ebc66f80] {
    font-size: 22px;
  }
  .g-desc[data-v-ebc66f80] {
    color: #999;
    margin-top: 10px;
  }
  .g-price[data-v-ebc66f80] {
    margin-top: 10px;
  }
  .g-price span[data-v-ebc66f80]:before {
    content: "Â¥";
    font-size: 14px;
  }
  .g-price span[data-v-ebc66f80]:first-child {
    color: #cf4444;
    margin-right: 10px;
    font-size: 22px;
  }
  .g-price span[data-v-ebc66f80]:last-child {
    color: #999;
    text-decoration: line-through;
    font-size: 16px;
  }
  .g-service[data-v-ebc66f80] {
    background: #f5f5f5;
    width: 500px;
    padding: 20px 10px 0 10px;
    margin-top: 10px;
  }
  .g-service dl[data-v-ebc66f80] {
    padding-bottom: 20px;
    display: flex;
    align-items: center;
  }
  .g-service dl dt[data-v-ebc66f80] {
    width: 50px;
    color: #999;
  }
  .g-service dl dd[data-v-ebc66f80] {
    color: #666;
  }
  .g-service dl dd:last-child span[data-v-ebc66f80] {
    margin-right: 10px;
  }
  .g-service dl dd:last-child span[data-v-ebc66f80]:before {
    content: "â€¢";
    color: #27ba9b;
    margin-right: 2px;
  }
  .g-service dl dd:last-child a[data-v-ebc66f80] {
    color: #27ba9b;
  }
  .goods-sku[data-v-3d8edf08] {
    padding-left: 10px;
    padding-top: 20px;
  }
  .goods-sku dl[data-v-3d8edf08] {
    display: flex;
    padding-bottom: 20px;
    align-items: center;
  }
  .goods-sku dl dt[data-v-3d8edf08] {
    width: 50px;
    color: #999;
  }
  .goods-sku dl dd[data-v-3d8edf08] {
    flex: 1;
    color: #666;
  }
  .goods-sku dl dd > img[data-v-3d8edf08] {
    width: 50px;
    height: 50px;
    border: 1px solid #e4e4e4;
    margin-right: 10px;
    cursor: pointer;
  }
  .goods-sku dl dd > img.selected[data-v-3d8edf08] {
    border-color: #27ba9b;
  }
  .goods-sku dl dd > img.disabled[data-v-3d8edf08] {
    opacity: 0.6;
    border-style: dashed;
    cursor: not-allowed;
  }
  .goods-sku dl dd > span[data-v-3d8edf08] {
    display: inline-block;
    height: 30px;
    line-height: 28px;
    padding: 0 20px;
    border: 1px solid #e4e4e4;
    margin-right: 10px;
    cursor: pointer;
  }
  .goods-sku dl dd > span.selected[data-v-3d8edf08] {
    border-color: #27ba9b;
  }
  .goods-sku dl dd > span.disabled[data-v-3d8edf08] {
    opacity: 0.6;
    border-style: dashed;
    cursor: not-allowed;
  }
  .goods-detail[data-v-4d87a5c2] {
    padding: 40px;
  }
  .goods-detail .attrs[data-v-4d87a5c2] {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 30px;
  }
  .goods-detail .attrs li[data-v-4d87a5c2] {
    display: flex;
    margin-bottom: 10px;
    width: 50%;
  }
  .goods-detail .attrs li .dt[data-v-4d87a5c2] {
    width: 100px;
    color: #999;
  }
  .goods-detail .attrs li .dd[data-v-4d87a5c2] {
    flex: 1;
    color: #666;
  }
  .goods-detail > img[data-v-4d87a5c2] {
    width: 100%;
  }
  .goods-comment-image .list {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
  }
  .goods-comment-image .list a {
    width: 120px;
    height: 120px;
    border: 1px solid #e4e4e4;
    margin-right: 20px;
    margin-bottom: 10px;
  }
  .goods-comment-image .list a img {
    width: 100%;
    height: 100%;
    -o-object-fit: contain;
    object-fit: contain;
  }
  .goods-comment-image .list a.active {
    border-color: #27ba9b;
  }
  .preview {
    width: 480px;
    height: 480px;
    border: 1px solid #e4e4e4;
    background: #f8f8f8;
    margin-bottom: 20px;
    position: relative;
  }
  .preview img {
    width: 100%;
    height: 100%;
    -o-object-fit: contain;
    object-fit: contain;
  }
  .preview i {
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 30px;
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    text-align: center;
    line-height: 30px;
  }
  .goods-comment .head {
    display: flex;
    padding: 30px 0;
  }
  .goods-comment .head .data {
    width: 340px;
    display: flex;
    padding: 20px;
  }
  .goods-comment .head .data p {
    flex: 1;
    text-align: center;
  }
  .goods-comment .head .data p span {
    display: block;
  }
  .goods-comment .head .data p span:first-child {
    font-size: 32px;
    color: #cf4444;
  }
  .goods-comment .head .data p span:last-child {
    color: #999;
  }
  .goods-comment .head .tags {
    flex: 1;
    display: flex;
    border-left: 1px solid #f5f5f5;
  }
  .goods-comment .head .tags .dt {
    font-weight: 700;
    width: 100px;
    text-align: right;
    line-height: 42px;
  }
  .goods-comment .head .tags .dd {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
  }
  .goods-comment .head .tags .dd > a {
    width: 132px;
    height: 42px;
    margin-left: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    border: 1px solid #e4e4e4;
    background: #f5f5f5;
    color: #999;
    text-align: center;
    line-height: 40px;
  }
  .goods-comment .head .tags .dd > a:hover {
    border-color: #27ba9b;
    background: #e6faf6;
    color: #27ba9b;
  }
  .goods-comment .head .tags .dd > a.active {
    border-color: #27ba9b;
    background: #27ba9b;
    color: #fff;
  }
  .goods-comment .sort {
    height: 60px;
    line-height: 60px;
    border-top: 1px solid #f5f5f5;
    border-bottom: 1px solid #f5f5f5;
    margin: 0 20px;
    color: #666;
  }
  .goods-comment .sort > span {
    margin-left: 20px;
  }
  .goods-comment .sort > a {
    margin-left: 30px;
    display: inline-block;
  }
  .goods-comment .sort > a.active,
  .goods-comment .sort > a:hover {
    color: #27ba9b;
  }
  .goods-comment .list {
    padding: 0 14px;
  }
  .goods-comment .list .item {
    display: flex;
    padding: 25px 10px;
    border-bottom: 1px solid #f5f5f5;
  }
  .goods-comment .list .item .user {
    width: 160px;
  }
  .goods-comment .list .item .user img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
  }
  .goods-comment .list .item .user span {
    padding-left: 10px;
    color: #666;
  }
  .goods-comment .list .item .body {
    flex: 1;
  }
  .goods-comment .list .item .body .score {
    line-height: 40px;
  }
  .goods-comment .list .item .body .score .iconfont {
    color: #ff9240;
    padding-right: 3px;
  }
  .goods-comment .list .item .body .score .attr {
    padding-left: 10px;
    color: #666;
  }
  .goods-comment .list .item .text {
    color: #666;
    line-height: 24px;
  }
  .goods-comment .list .item .time {
    color: #999;
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
  }
  .goods-tabs {
    min-height: 600px;
    background: #fff;
  }
  .goods-tabs nav {
    height: 70px;
    line-height: 70px;
    display: flex;
    border-bottom: 1px solid #f5f5f5;
  }
  .goods-tabs nav a {
    padding: 0 40px;
    font-size: 18px;
    position: relative;
  }
  .goods-tabs nav a > span {
    color: #cf4444;
    font-size: 16px;
    margin-left: 10px;
  }
  .goods-tabs nav a:first-child {
    border-right: 1px solid #f5f5f5;
  }
  .goods-tabs nav a.active:before {
    content: "";
    position: absolute;
    left: 40px;
    bottom: -1px;
    width: 72px;
    height: 2px;
    background: #27ba9b;
  }
  .goods-item[data-v-1089b770] {
    display: block;
    width: 220px;
    padding: 20px 30px;
    text-align: center;
    transition: all 0.5s;
  }
  .goods-item[data-v-1089b770]:hover {
    transform: translate3d(0, -3px, 0);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  }
  .goods-item img[data-v-1089b770] {
    width: 160px;
    height: 160px;
  }
  .goods-item p[data-v-1089b770] {
    padding-top: 10px;
  }
  .goods-item .name[data-v-1089b770] {
    font-size: 16px;
  }
  .goods-item .desc[data-v-1089b770] {
    color: #999;
    height: 29px;
  }
  .goods-item .price[data-v-1089b770] {
    color: #cf4444;
    font-size: 20px;
  }
  .goods-hot h3[data-v-3e75e67a] {
    height: 70px;
    background: #e26237;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: 400;
  }
  .goods-hot[data-v-3e75e67a] .goods-item {
    background: #fff;
    width: 100%;
    margin-bottom: 10px;
  }
  .goods-hot[data-v-3e75e67a] .goods-item img {
    width: 200px;
    height: 200px;
  }
  .goods-hot[data-v-3e75e67a] .goods-item p {
    margin: 0 10px;
  }
  .goods-hot[data-v-3e75e67a] .goods-item:hover {
    transform: none;
    box-shadow: none;
  }
  .goods-warn[data-v-6867108e] {
    margin-top: 20px;
    background: #fff;
    padding-bottom: 40px;
  }
  .goods-warn h3[data-v-6867108e] {
    height: 70px;
    line-height: 70px;
    border-bottom: 1px solid #f5f5f5;
    padding-left: 50px;
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 10px;
  }
  .goods-warn p[data-v-6867108e] {
    line-height: 40px;
    padding: 0 25px;
    color: #666;
  }
  .goods-warn p.tit[data-v-6867108e] {
    color: #333;
  }
  .goods-info {
    min-height: 600px;
    background: #fff;
    display: flex;
  }
  .goods-info .media {
    width: 580px;
    height: 600px;
    padding: 30px 50px;
  }
  .goods-info .spec {
    flex: 1;
    padding: 30px 30px 30px 0;
  }
  .goods-footer {
    display: flex;
    margin-top: 20px;
  }
  .goods-footer .goods-article {
    width: 940px;
    margin-right: 20px;
  }
  .goods-footer .goods-aside {
    width: 280px;
    min-height: 1000px;
  }
  .xtx-pagination {
    display: flex;
    justify-content: center;
    padding: 30px;
  }
  .xtx-pagination > a.active {
    background: #27ba9b;
    color: #fff;
    border-color: #27ba9b;
  }
  .xtx-pagination > a {
    display: inline-block;
    padding: 5px 10px;
    border: 1px solid #e4e4e4;
    border-radius: 4px;
    margin-right: 10px;
  }
  a {
    text-decoration: none;
    color: #333;
    outline: none;
  }
  a {
    background-color: transparent;
  }
  </style>